#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void sort(int a[], int a1) {
    while(a1--)     {
        bool a2 = false;
        
        for(int i = 0; i < a1; i++) {
            if(a[i] > a[i + 1]){
                swap(a[i], a[i + 1]);
                a2 = true;
            }
        }    
    
        if(a2 == false) break;
    }
}

void read_from_file(const char *filename, int a[], int length) {
    ifstream file(filename);

    for(int i=0; i < length; i++)
        file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    read_from_file("m1_sorted.txt",a,LEN);
    unsigned int a5 =  clock(); 
    sort(a,LEN);
    unsigned int a6 = clock(); 
    unsigned int a7 = a6 - a5; 
    cout<<"m1_sorted " << a7 << " milliseconds \n";
    
    read_from_file("m2_reverse.txt",a,LEN);
    a5 =  clock();
    sort(a,LEN);
    a6 = clock(); 
    a7 = a6 - a5; 
    cout<<"m2_reverse " << a7 << " milliseconds \n";
    
    read_from_file("m3_shuffle.txt",a,LEN);
    a5 =  clock(); 
    sort(a,LEN);
    a6 = clock(); 
    a7 = a6 - a5; 
    cout<<"m3_shuffle " << a7 << " milliseconds \n";
    
    return 0;
}